package com.example.run.teacherhelper.Activities;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.example.run.teacherhelper.Fragments.AccountFragment;
import com.example.run.teacherhelper.Fragments.Class_Info_Fragment;
import com.example.run.teacherhelper.Fragments.StasticsDataFragment;
import com.example.run.teacherhelper.R;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private ImageView homeimg;
    private ImageView messageimg;
    private ImageView accountimg;
    private LinearLayout homebtn;
    private LinearLayout messagebtn;
    private LinearLayout accountbtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
        setOnListener();
    }

    protected void initView(){
        homebtn=(LinearLayout)findViewById(R.id.home_btn);
        messagebtn=(LinearLayout)findViewById(R.id.message_btn);
        accountbtn=(LinearLayout)findViewById(R.id.account_btn);
        homeimg=(ImageView)findViewById(R.id.home_img);
        messageimg=(ImageView)findViewById(R.id.message_img);
        accountimg=(ImageView)findViewById(R.id.account_img);
        Class_Info_Fragment class_info_fragment=new Class_Info_Fragment();
       getSupportFragmentManager().beginTransaction().
               replace(R.id.fragment_replace,class_info_fragment).commit();

    }

    protected void initData(){

    }

    protected void setOnListener(){
        homebtn.setOnClickListener(this);
        messagebtn.setOnClickListener(this);
        accountbtn.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.home_btn:
                Class_Info_Fragment class_info_fragment=new Class_Info_Fragment();
                getSupportFragmentManager().beginTransaction().
                        replace(R.id.fragment_replace,class_info_fragment).commit();
                homeimg.setImageResource(R.drawable.ia_home_selected);
                messageimg.setImageResource(R.drawable.ia_message);
                accountimg.setImageResource(R.drawable.ia_account);

                break;
            case R.id.account_btn:
                AccountFragment accountFragment=new AccountFragment();
                getSupportFragmentManager().beginTransaction().
                        replace(R.id.fragment_replace,accountFragment).commit();
                homeimg.setImageResource(R.drawable.ia_home);
                messageimg.setImageResource(R.drawable.ia_message);
                accountimg.setImageResource(R.drawable.ia_account_selected);
                break;
            case R.id.message_btn:
                StasticsDataFragment stasticdataFragment=new StasticsDataFragment();
                getSupportFragmentManager().beginTransaction().
                        replace(R.id.fragment_replace,stasticdataFragment).commit();
                homeimg.setImageResource(R.drawable.ia_home);
                messageimg.setImageResource(R.drawable.ia_message_selected);
                accountimg.setImageResource(R.drawable.ia_account);
                break;

        }

    }
}
